<?php
// +----------------------------------------------------------------------
// |  全局常量
// +----------------------------------------------------------------------
//三方消息通知域名
const APP_NOTIFY_DOMAIN = YII_ENV_PROD ? 'https://prod.notify.example.com' : 'https://dev.notify.example.com';
//附件访问域名
const APP_FILE_DOMAIN = 'https://images.s2.example.com';
//七牛云访问秘钥
const APP_QINIU_ACCESS_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
//七牛云账号秘钥
const APP_QINIU_SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
//七牛云空间名
const APP_QINIU_BUKET_NAME = 'files';

// +----------------------------------------------------------------------
// |  模块自动加载和别名
// +----------------------------------------------------------------------
Yii::setAlias('@root', dirname(dirname(__DIR__)));
Yii::setAlias('@common', dirname(__DIR__));
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
Yii::setAlias('@notify', dirname(dirname(__DIR__)) . '/notify');
Yii::setAlias('@builder', dirname(dirname(__DIR__)) . '/builder');
Yii::setAlias('@extend', dirname(dirname(__DIR__)) . '/extend');
Yii::setAlias('@messages', dirname(dirname(__DIR__)) . '/messages');

// +----------------------------------------------------------------------
// |  常用正则 - PHP
// +----------------------------------------------------------------------
// 手机号正则
const PHP_MOBILE_REGEX = '/^1((3|4|5|6|7|8|9){1}\d{1})\d{8}$/';
// 邮箱正则
const PHP_EMAIL_REGEX = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
// 身份证号正则
const PHP_ID_CARD_REGEX = '/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/';
// IP正则
const PHP_IP_REGEX = '/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/';
// URL正则
const PHP_URL_REGEX = '/^http[s]?:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/';
// 账号正则
const PHP_USERNAME_REGEX = '/^[a-z0-9_\x{4e00}-\x{9fa5}]+$/ui';
// 密码正则
const PHP_PASSWORD_REGEX = '/^(?=.*[a-zA-Z])(?=.*[\d\W]).{8,}|(?=.*\d)(?=.*[\W[a-zA-Z]]).{8,}|(?=.*\W)(?=.*[a-zA-Z\d]).{8,}$/';
//快递单号正则
const PHP_LOGISTICS_NO_REGEX = '/^[A-Z0-9_]{6,}$/i';

// +----------------------------------------------------------------------
// |  常用正则 - Javascript
// +----------------------------------------------------------------------
// 手机号正则
const JS_MOBILE_REGEX = '/^1((3|4|5|6|7|8|9){1}\d{1})\d{8}$/';
// 邮箱正则
const JS_EMAIL_REGEX = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/';

// +----------------------------------------------------------------------
// |  常用函数
// +----------------------------------------------------------------------
if (YII_DEBUG) {
    if (!function_exists('dd')) {
        /**
         * 调试打印
         * @since php5.6
         * @param $mixed
         */
        function dd(...$mixed)
        {
            if (count($mixed) == 1) {
                $mixed = $mixed[0];
            }

            \builder\helper\D::dd($mixed);
        }
    }
}
